package nero.yncc.com.createart.utils;

import android.app.Activity;

import java.util.HashMap;

import nero.yncc.com.createart.base.Constants;
import nero.yncc.com.createart.bean.UserBean;

/**
 * Created by nero on 17-7-6.
 */

public class ShopCarUtil  {

    public static  void getShopCarNum(Activity activity, UserBean userBean, final ShopCarGetListener listener){
        HashMap<String,String> hashMap=new HashMap<>();
        hashMap.put("user_id",userBean.getUser_id());
        HttpUtils.get(activity, Constants.API_SHOP_CAR_NUM, hashMap, null, HttpUtils.TYPE_NOTHING, new HttpUtils.HttpCallback() {
            @Override
            public void success(String msg, Object json) {
                listener.success((String)json);
            }

            @Override
            public void fail(String failMsg) {
                listener.fail(failMsg);
            }
        });
    }

    public interface ShopCarGetListener{
         void success(String num);
         void fail(String num);
    }

    public static void changeShopCarNum(Activity activity, UserBean userBean, final String id, String content, final ShopCarGetListener listener){
        HashMap<String, String> hashMap = new HashMap<>();
        hashMap.put("action","MODIFY" );
        hashMap.put("id", id);
        hashMap.put("content", content);
        hashMap.put("user_id", userBean.getUser_id());

        new HttpUtils().post(activity, Constants.API_SHOPCAR_CHANGE, hashMap, null, HttpUtils.TYPE_NOTHING, new HttpUtils.HttpCallback() {
            @Override
            public void success(String msg, Object json) {
                listener.success(id);
            }

            @Override
            public void fail(String failMsg) {
                listener.fail(id);
            }
        });
    }

}
